package com.iteye.trafficRecorder;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class Setting {
	
	private SharedPreferences sharedPreferences;
	
	public Setting(Context context) {
		sharedPreferences = context.getSharedPreferences("setting", Activity.MODE_PRIVATE);
	}
	
	public String getWebServiceUrl() {
		return "http://"+getWebServiceAddress()+"/Communicate.asmx/SetData";
		//return "http://"+getWebServiceAddress()+"/_Communicate.asmx/SetData";
	}
	
	public String getWebServiceAddress() {
		return sharedPreferences.getString( "webservice_address", "112.4.74.93:3001");
	}

	public void setWebServiceAddress(String webServiceAddress) {
		SharedPreferences.Editor editor = sharedPreferences.edit();
		editor.putString("webservice_address", webServiceAddress);
		editor.commit();
	}

	public int getGpsRecordsecond() {
		return sharedPreferences.getInt("gps_record_second", 10);
	}

	public void setGpsRecordsecond(int gpsRecordsecond) {
		SharedPreferences.Editor editor = sharedPreferences.edit();
		editor.putInt("gps_record_second", gpsRecordsecond);
		editor.commit();
	}

	public boolean isStoreLocal() {
		return sharedPreferences.getBoolean("store_local", false);
	}

	public void setStoreLocal(boolean storeLocal) {
		SharedPreferences.Editor editor = sharedPreferences.edit();
		editor.putBoolean("store_local", storeLocal);
		editor.commit();
	}

}
